/**
 * 
 */
package systole.domain.signals;

import java.io.Serializable;
import java.math.BigDecimal;
import java.text.DecimalFormat;
import java.text.Format;
import java.util.Calendar;

/**
 * @author jmj
 *
 */
public class SignalFrequency implements Serializable {

    /**
     *
     */
    private static final long serialVersionUID = -3160781206441870556L;
    private Integer id;
    private BigDecimal frequency;
    private String description;
    private Calendar lastUpdate;

    /**
     * Empty Constructor.
     */
    public SignalFrequency() {
        super();
    }

    /**
     * Full Constructor.
     *
     * @param id
     * @param frequency
     * @param description
     */
    public SignalFrequency(Integer id, BigDecimal frequency, String description) {
        super();
        this.id = id;
        this.frequency = frequency;
        this.description = description;
    }

    /**
     * @param id the id to set
     */
    public void setId(Integer id) {
        this.id = id;
    }

    /**
     * @return the id
     */
    public Integer getId() {
        return this.id;
    }

    /**
     * @param frequency the frequency to set
     */
    public void setFrequency(BigDecimal frequency) {
        this.frequency = frequency;
    }

    /**
     * @return the frequency
     */
    public BigDecimal getFrequency() {
        return this.frequency;
    }

    /**
     * @param description the description to set
     */
    public void setDescription(String description) {
        this.description = description;
    }

    /**
     * @return the description
     */
    public String getDescription() {
        return this.description;
    }

    /**
     * @return the lastUpdate
     */
    public Calendar getLastUpdate() {
        return lastUpdate;
    }

    /**
     * @param lastUpdate the lastUpdate to set
     */
    public void setLastUpdate(Calendar lastUpdate) {
        this.lastUpdate = lastUpdate;
    }

    @Override
    public String toString() {
        Format format = new DecimalFormat();
        return this.description + " " + format.format(this.frequency);
    }


    /* (non-Javadoc)
     * @see java.lang.Object#hashCode()
     */
    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result
                + ((this.description == null) ? 0 : this.description.hashCode());
        result = prime * result
                + ((this.frequency == null) ? 0 : this.frequency.hashCode());
        result = prime * result + ((this.id == null) ? 0 : this.id.hashCode());
        return result;
    }


    /* (non-Javadoc)
     * @see java.lang.Object#equals(java.lang.Object)
     */
    @Override
    public boolean equals(Object obj) {
        if (this == obj) {
            return true;
        }
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        SignalFrequency other = (SignalFrequency) obj;
        if (this.description == null) {
            if (other.description != null) {
                return false;
            }
        } else if (!this.description.equals(other.description)) {
            return false;
        }
        if (this.frequency == null) {
            if (other.frequency != null) {
                return false;
            }
        } else if (!this.frequency.equals(other.frequency)) {
            return false;
        }
        if (this.id == null) {
            if (other.id != null) {
                return false;
            }
        } else if (!this.id.equals(other.id)) {
            return false;
        }
        return true;
    }
}
